﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Script.Serialization;
using Newtonsoft.Json;

namespace LanguageInfo.Common.Utilities
{
	/// <summary>
	/// 描述：JSON序列化帮助类
	/// 作者：路晓阳
	/// 时间：2010-6-1
	/// </summary>
	public class JsonHelper
	{
		/// <summary>
		/// 序列化为json字符串
		/// </summary>
		/// <param name="obj"></param>
		/// <returns></returns>
		public static string Serializer(object obj)
		{
            return JsonConvert.SerializeObject(obj);		
		}

		/// <summary>
		/// 将json字符串反序列化为对象T
		/// </summary>
		/// <param name="obj"></param>
		/// <returns></returns>
		public static T Deserialize<T>(string json)
		{
            return JsonConvert.DeserializeObject<T>(json);
		}

	}
}
